<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
<title>提现记录</title>
<base href="<%=basePath%>" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="icon" type="image/png" href="i/buyu.ico">
<link rel="stylesheet" href="layui/css/layui.css" media="all" />
<style>
.layui-form {
    margin-top : 2em;
    margin-left : 2em;
}
</style>
</head>
<body>
	  <form class="layui-form" action="" onsubmit='return false'>
		<div class="layui-form-item">
			<div class="layui-inline">
				<div class="layui-input-inline">
					<input type="text" name="OrderID"  id="OrderID" placeholder="请输入订单号" autocomplete="off"
						class="layui-input">
				</div>
				<div class="layui-input-inline">
					<input type="text" name="UserId"  id="UserId" placeholder="请输入玩家ID" autocomplete="off"
						class="layui-input">
				</div>
				 <div class="layui-input-inline">
	               <select name="Statesend" id="Statesend" placeholder="全部状态" lay-filter="Statesend">
		             <option value="0">全部状态</option>
		             <option value="1">未处理</option>
		             <option value="2">已提现</option>
		             <option value="3">拒绝提现</option>
	               </select>
	             </div>
	             <div class="layui-input-inline">
                   <input type="text" class="layui-input" id="startRedeemTime" placeholder="开始兑换时间"  lay-filter="startRedeemTime" name="startRedeemTime" autocomplete="off">
                 </div>
                 <div class="layui-input-inline">
                   <input type="text" class="layui-input" id="endRedeemTime" placeholder="结束兑换时间"  lay-filter="endRedeemTime" name="endRedeemTime" autocomplete="off">
                 </div>
                 <div class="layui-input-inline">
                   <input type="text" class="layui-input" id="startHandleTime" placeholder="开始处理时间"  lay-filter="startHandleTime" name="startHandleTime"autocomplete="off">
                 </div>
                 <div class="layui-input-inline">
                   <input type="text" class="layui-input" id="endHandleTime" placeholder="结束处理时间"  lay-filter="endHandleTime" name="endHandleTime" autocomplete="off">
                 </div>
                 <div class="layui-input-inline">
			       <button class="layui-btn layui-btn-normal"  data-type="reload" id="selectbyCondition" onsubmit="return false;">搜索</button>
				   <button type="reset" class="layui-btn layui-btn-primary">重置</button>
			     </div>
			</div>
          </div>
		</form>
	    <table class="layui-table" lay-skin="nob" id="Cashoutlist" lay-filter="Cashoutlist"></table>
	   
	    <script src="js/jquery.min.js"></script>
		<script src="layui/layui.js"></script>
		
		<script type="text/html" id="State">
              {{#  if(d.State == 0){ }}
                 <span>未发货</span>
              {{#  } else if(d.State == 1){ }}
                 <span style="color:#1d953f">已发货</a>
              {{#  } else if(d.State == 2){ }}
                 <span style="color:#d71345">拒绝发货</a>
              {{#  } }}
        </script>
		
		<script type="text/html" id="tool">
              {{#  if(d.State == 0){ }}
                 <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="edit1">未发货</a>
              {{#  } else if(d.State == 1){ }}
                 <a class="layui-btn layui-btn-xs" lay-event="edit2">已发货</a>
              {{#  } else if(d.State == 2){ }}
                 <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="edit3">拒绝发货</a>
              {{#  } }}
        </script>
        <script type="text/html" id="ItemCount">
              {{# d.ItemCount = parseInt(d.ItemCount)/100 }}
                 <span style="color:#f15b6c;">{{ d.ItemCount }}</span>
        </script>
		
	    <script type="text/javascript">

			layui.use(['form', 'layer', 'table', 'laydate'], function() {
			var form = layui.form;
			var layer = layui.layer;
			var table = layui.table;
			var laydate = layui.laydate;

			layer.config({
				extend: 'MySkin/style.css'
			});
				
            table.render({
				elem:'#Cashoutlist',
				url:'charge/CashOut',
				method:'post',
				title:'提现列表',
				page:true,
				cellMinWidth:80,
				id:'AllTable',
				request:{
					pageName:'PageIndex',
					limitName:'PageCount'
				},
				where:{
					OrderID : $('#OrderID').val(),
					UserId : $('#UserId').val(),
					Statesend : $('#Statesend').val(),
					startRedeemTime : $('#startRedeemTime').val(),
					endRedeemTime : $('#endRedeemTime').val(),
					startHandleTime : $('#startHandleTime').val(),
					endHandleTime : $('#endHandleTime').val()
				},
				cols : [ [ 
					{
					field : 'OrderId',title : '订单号'}, 
					{field : 'Nickname',title : '用户昵称'}, 
					{field : 'UserId',title : '玩家ID'}, 
					{field : 'ItemCount',title : '提现金额(元)',templet:'#ItemCount'}, 
					{field : 'BankCardId',title : '银行卡号'}, 
					{field : 'BankName',title : '银行名称'}, 
					{field : 'RealName',title : '真实姓名'},
					{field : 'State',title : '订单状态',templet:'#State'}, 
					{field : 'CreateTime',title : '请求时间'},
					{field : 'ProcessTime',title : '处理时间'},
					{title : '操作',fixed : 'right',align : 'center',toolbar:'#tool'} 
				] ],
				page : true,//分页
				response : {
					statusCode : 200
				//重新规定成功的状态码为 200，table 组件默认为 0
				},
				parseData : function(res) { //将原始数据解析成 table 组件所规定的数据
					return {
						"code" : res.status, //解析接口状态
						"msg" : res.message, //解析提示文本
						"count" : res.count, //解析数据长度
						"data" : res.data
					//解析数据列表
					};
				}
			});
            
            
            //根据条件查询表格数据重新加载
		    var active = {
			  reload: function(){
			    //执行重载
			    table.reload('AllTable', {
			        page: {
			          curr: 1 //重新从第 1 页开始
			      }
			      //根据条件查询
			      ,where: {
			        OrderID : $('#OrderID').val(),
					UserId : $('#UserId').val(),
					Statesend : $('#Statesend').val(),
					startRedeemTime : $('#startRedeemTime').val(),
					endRedeemTime : $('#endRedeemTime').val(),
					startHandleTime : $('#startHandleTime').val(),
					endHandleTime : $('#endHandleTime').val()
			      }
			    });
			    return false;
			   }
			};
		    //点击搜索按钮根据用户名称查询
		    $('#selectbyCondition').on('click',
	          function(){
	              var type = $(this).data('type');
	              active[type] ? active[type].call(this) : '';
	        });
		    
		  //监听行工具事件
		  table.on('tool(Cashoutlist)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
		    var data = obj.data //获得当前行数据
		    ,layEvent = obj.event; //获得 lay-event 对应的值
		    if(layEvent === 'edit1'){
		    	let userid = data.UserId;
		    	layer.open({
		    	  area: ['400px', '150px'],
		    	  title: '是否发货',
		    	  skin: 'layer-ext-yourskin',
		          content: '确定通过玩家<span style="color:red;">' + userid + '</span>的申请提现吗 ?'
		    	  ,btn:['直接支付','使用代付','拒绝发货','退出']
				  ,yes : function(index, layero){
					  let info = new Object();
					  info.orderId = data.OrderId ,
					  info.state = 1;
					  info.rechargeType = 0;
					  var loadingIndex = layer.msg('提交中..', {
		    			    icon: 16
		    			    ,shade: 0.3
		    			    ,time: false
		    			});
		    	    $.ajax({
	    				type:"POST",
	    				url:'recharge/CashOutEnsure',
	    				async: true,
	    				dataType:'json',
	    				contentType:'application/json',
	    				data:JSON.stringify(info),
	    				success : function(resp) {
	    					layer.close(loadingIndex);
	    					if (resp.message === null) {
	    						setTimeout(function(){
	    						    layer.msg("修改成功",{icon:6});
	    							table.reload('AllTable',{});
	    						},1000);
	    					}else {
	    						setTimeout(function(){
	    						    layer.msg(resp.message,{icon:6});
	    							table.reload('AllTable',{});
	    						},1000);
	    					}
	    					obj = null;
	    				    data = null;
	    				    layEvent = null;
	    				}	
	    			});
				}
		    	,btn2 : function(index, layero){
		    		let info = new Object();
					  info.orderId = data.OrderId ,
					  info.state = 1;
					  info.rechargeType = 1;
					  var loadingIndex = layer.msg('提交中..', {
		    			    icon: 16
		    			    ,shade: 0.3
		    			    ,time: false
		    			});
					$.ajax({
	    				type:"POST",
	    				url:'recharge/CashOutEnsure',
	    				async: true,
	    				dataType:'json',
	    				contentType:'application/json',
	    				data:JSON.stringify(info),
	    				success : function(resp) {
	    					layer.close(loadingIndex);
	    					if (resp.message === null) {
	    						setTimeout(function(){
	    						    layer.msg("修改成功",{icon:6});
	    							table.reload('AllTable',{});
	    						},1000);
	    					}else {
	    						setTimeout(function(){
	    						    layer.msg(resp.message,{icon:6});
	    							table.reload('AllTable',{});
	    						},1000);
	    					}
	    				    obj = null;
	    				    data = null;
	    				    layEvent = null;
	    				}	
	    			});
					return false;
				}
				,btn3 : function(index, layero){
					let info = new Object();
					info.orderId = data.OrderId ,
					info.state = 2;
					var loadingIndex = layer.msg('提交中..', {
	    			    icon: 16
	    			    ,shade: 0.3
	    			    ,time: false
	    			});
					$.ajax({
	    				type:"POST",
	    				url:'recharge/CashOutEnsure',
	    				async: true,
	    				dataType:'json',
	    				contentType:'application/json',
	    				data:JSON.stringify(info),
	    				success : function(resp) {
	    					layer.close(loadingIndex);
	    					if (resp.message === null) {
	    						setTimeout(function(){
	    						    layer.msg("修改成功",{icon:6});
	    							table.reload('AllTable',{});
	    						},1000);
	    					}else {
	    						setTimeout(function(){
	    						    layer.msg(resp.message,{icon:6});
	    							table.reload('AllTable',{});
	    						},1000);
	    					}
	    					obj = null;
	    				    data = null;
	    				    layEvent = null;
	    				}	
	    			});
					return false;
				}
				,btn4 : function(index){
				}
			});
		    }else if(layEvent == 'edit2'){
		    }else if(layEvent == 'edit3'){
		    }
		  });
		    
		    setInterval(function(){
			  table.reload('AllTable', {
			        page: {
			          curr: 1 //重新从第 1 页开始
			      }
			      //根据条件查询
			        ,where: {
			        	OrderID : $('#OrderID').val(),
						UserId : $('#UserId').val(),
						Statesend : $('#Statesend').val(),
						startRedeemTime : $('#startRedeemTime').val(),
						endRedeemTime : $('#endRedeemTime').val(),
						startHandleTime : $('#startHandleTime').val(),
						endHandleTime : $('#endHandleTime').val()
			        }
			      });
	        },60000);
            
            
            //日期选择器
			laydate.render({
			    elem: '#startRedeemTime'
			    ,type: 'datetime' 
			  });
			laydate.render({
				elem: '#endRedeemTime'
				,type: 'datetime' 
			});
			laydate.render({
			    elem: '#startHandleTime'
			    ,type: 'datetime' 
			  });
			laydate.render({
				elem: '#endHandleTime'
				,type: 'datetime' 
			});
	      });
        </script>

</body>
</html>